package com.tisson.action;

import java.util.ArrayList;
import java.util.List;

import com.tisson.comment.WebConstants;
import com.tisson.dao.AdminDAO;
import com.tisson.pojo.Page;

public class SysManageAction extends ActionSup {
	private List infoList;
	private Page page;

	public List getInfoList() {
		return infoList;
	}

	public void setInfoList(List infoList) {
		this.infoList = infoList;
	}

	public String manage() {
		AdminDAO dao = new AdminDAO();
		List list = dao.findAll();
		infoList = new ArrayList();
		for (int i = 0; i < WebConstants.PAGESIZE; i++) {
			if (i < list.size()) {
				infoList.add(list.get(i));
			}
		}
		page = new Page();
		page.setCurrentPage(1);
		page.setPrePage(page.getCurrentPage() - 1);
		page.setNextPage(page.getCurrentPage() + 1);
		page.setListSize(list.size());
		int remind = page.getListSize() % WebConstants.PAGESIZE;
		int total = page.getListSize() / WebConstants.PAGESIZE;
		page.setTotalPages(remind == 0 ? total : total + 1);
		request.getSession().setAttribute("list", list);
		return "success";
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}
}
